home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 1.toast / Sample Code / Networking / ARPSample / OTARPModule.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-09-28  |  7.3 KB  |  205 lines  |  [TEXT/CWIE]

  1. /*
  2.     File:        OTARPModule.h
  3.  
  4.     Contains:    Types and constants to interface to the OT ARP module.
  5.  
  6.     Written by: Quinn "The Eskimo!"    
  7.  
  8.     Copyright:    Copyright © 1997-1999 by Apple Computer, Inc., All Rights Reserved.
  9.  
  10.                 You may incorporate this Apple sample source code into your program(s) without
  11.                 restriction. This Apple sample source code has been provided "AS IS" and the
  12.                 responsibility for its operation is yours. You are not permitted to redistribute
  13.                 this Apple sample source code as "Apple sample source code" after having made
  14.                 changes. If you're going to re-distribute the source, we require that you make
  15.                 it clear in the source that the code was descended from Apple sample source
  16.                 code, but that you've made changes.
  17.  
  18.     Change History (most recent first):
  19.                 7/21/1999    Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
  20.                 
  21.  
  22. */
  23.  
  24. #if PRAGMA_ALIGN_SUPPORTED
  25. #pragma options align=mac68k
  26. #endif
  27.  
  28. ///////////////////////////////////////////////////////////////////
  29.  
  30. // Pick up the standard UInt32 types.
  31.  
  32. #include <Types.h>
  33.  
  34. // Pick up the MIOC_CMD macro.
  35.  
  36. #include <OpenTransport.h>
  37.  
  38. // Pick up queue_t.
  39.  
  40. #include <mistream.h>
  41.  
  42. // Pick up the MIOC_ARP constants.
  43.  
  44. // #include <miioccom.h>
  45.  
  46. // This constant is actually defined in <miioccom.h>, but
  47. //  commented out for some reason )-:
  48.  
  49. #define MIOC_ARP        'h'        /* ioctl's for Mentat's arp module */
  50.  
  51. ///////////////////////////////////////////////////////////////////
  52.  
  53. // ARP Command Structures 
  54.  
  55. // arc_t is the standard header for all ARP command structures.
  56. // The structure you should use is determined by the arc_cmd
  57. // field. See the command constants for details of which
  58. // structures to use with which commands..
  59.  
  60. typedef struct {
  61.     UInt32    arc_cmd;
  62.     UInt32    arc_name_offset;
  63.     UInt32    arc_name_length;
  64.     UInt32    arc_proto;
  65.     UInt32    arc_proto_addr_offset;
  66.     UInt32    arc_proto_addr_length;
  67.     UInt32    arc_flags;
  68.     queue_t * arc_client_q;        /* context save area for client module */
  69. } arc_t;
  70.  
  71. typedef    struct {
  72.     arc_t    area_arc;
  73.     UInt32    area_proto_mask_offset;
  74.     UInt32    area_hw_addr_offset;
  75.     UInt32    area_hw_addr_length;
  76. } area_t;
  77.  
  78. typedef    struct {
  79.     arc_t    areq_arc;
  80.     UInt32    areq_sender_addr_offset;
  81.     UInt32    areq_sender_addr_length;
  82.     UInt32    areq_xmit_count;    /* 0 ==> cache lookup only */
  83.     UInt32    areq_xmit_interval;    /* # of milliseconds; 0: default */
  84.     UInt32    areq_max_buffered;    /* # ofquests to buffer; 0: default */
  85.     UInt8    areq_sap[8];        /* to insert in returned template */
  86. } areq_t;
  87.  
  88. typedef    struct {
  89.     arc_t    arma_arc;
  90.     UInt32    arma_proto_mask_offset;
  91.     UInt32    arma_proto_extract_mask_offset;
  92.     UInt32    arma_hw_addr_offset;
  93.     UInt32    arma_hw_addr_length;
  94.     UInt32    arma_hw_mapping_start;    /* Offset to start of the mask&proto_addr */
  95. } arma_t;
  96.  
  97.  
  98. // ARP Command Codes for use in the arc_cmd field of arc_t,
  99. // along with the true structures you should use.
  100.  
  101. #define    AR_ENTRY_ADD        MIOC_CMD(MIOC_ARP,1)
  102. // Add an ARP cache entry.
  103. // Use area_t structure.
  104. // In:
  105. //        area_arc.arc_cmd = AR_ENTRY_ADD
  106. //        area_arc.arc_name_offset = offset to name of interface
  107. //        area_arc.arc_name_length = length of name of interface (including zero terminator)
  108. //        area_arc.arc_proto = ARP protocol type (eg IP_ARP_PROTO_TYPE)
  109. //        area_arc.arc_proto_addr_offset = offset to protocol address to look up (eg an InetHost)
  110. //        area_arc.arc_proto_addr_offset = length of protocol address to look up (eg sizeof(InetHost))
  111. //        area_arc.arc_flags = flags for this cache entry (see below)
  112. //        area_proto_mask_offset = offset to a protocol address mask (usually $FFFFFFFF)
  113. //        area_hw_addr_offset = offset to hardware address
  114. //        area_hw_addr_length = length of hardware address (eg 6)
  115.  
  116. #define    AR_MAPPING_ADD        MIOC_CMD(MIOC_ARP,7)
  117. // Use arma_t structure.
  118.  
  119. #define    AR_ENTRY_DELETE        MIOC_CMD(MIOC_ARP,2)
  120. // Delete an entry in the ARP cache.
  121. // Use arc_t structure.
  122. // In:
  123. //        arc_cmd = AR_ENTRY_DELETE
  124. //        arc_name_offset = offset to name of interface
  125. //        arc_name_length = length of name of interface (including zero terminator)
  126. //        arc_proto = ARP protocol type (eg IP_ARP_PROTO_TYPE)
  127. //        arc_proto_addr_offset = offset to protocol address to delete (eg an InetHost)
  128. //        arc_proto_addr_length = length of protocol address to delete (eg sizeof(InetHost))
  129.  
  130. #define    AR_ENTRY_QUERY        MIOC_CMD(MIOC_ARP,3)
  131. // Look for an entry, either in the cache or by talking on the network.
  132. // Use areq_t structure.
  133. // In:
  134. //        areq_arc.arc_cmd = AR_ENTRY_QUERY
  135. //        areq_arc.arc_name_offset = offset to name of interface
  136. //        areq_arc.arc_name_length = length of name of interface (including zero terminator)
  137. //        areq_arc.arc_proto = ARP protocol type (eg IP_ARP_PROTO_TYPE)
  138. //        areq_arc.arc_proto_addr_offset = offset to protocol address to look up (eg an InetHost)
  139. //        areq_arc.arc_proto_addr_offset = length of protocol address to look up (eg sizeof(InetHost))
  140. //        areq_sender_addr_offset = offset to protocol address of sender (eg an InetHost)
  141. //        areq_sender_addr_length = length of protocol address of sender (eg sizeof(InetHost))
  142. //        areq_xmit_count = number of transmissions before giving up (use 0 for a straight cache lookup)
  143. //        areq_xmit_interval = number of milliseconds between transmissions (0 gives a sensible default)
  144. //        areq_max_buffered = number of requests to buffer (0 gives a sensible default)
  145. //        areq_sap = a SAP to insert into the returned response
  146. // Out:
  147. //        The output is in the form of a DLPI message that you can
  148. //        use as the header to a message to the requested host.
  149.  
  150. #define    AR_ENTRY_SQUERY        MIOC_CMD(MIOC_ARP,6)
  151. // Look for an entry in the ARP cache.
  152. // Use area_t structure.
  153. // In:
  154. //        area_arc.arc_cmd = AR_ENTRY_SQUERY
  155. //        area_arc.arc_name_offset = offset to name of interface
  156. //        area_arc.arc_name_length = length of name of interface (including zero terminator)
  157. //        area_arc.arc_proto = ARP protocol type (eg IP_ARP_PROTO_TYPE)
  158. //        area_arc.arc_proto_addr_offset = offset to protocol address to look up (eg an InetHost)
  159. //        area_arc.arc_proto_addr_offset = length of protocol address to look up (eg sizeof(InetHost))
  160. //        area_hw_addr_offset = offset to buffer to store hardware address
  161. //        area_hw_addr_length = length of buffer to store hardware address (eg 6)
  162. // Out:
  163. //        area_arc.arc_flags = flags for this entry
  164. //        buffer pointed to by area_hw_addr_offset and area_hw_addr_length = hardware address
  165.  
  166. #define    AR_XMIT_REQUEST        MIOC_CMD(MIOC_ARP,4)
  167. // Use arc_t structure.
  168.  
  169. #define    AR_XMIT_RESPONSE    MIOC_CMD(MIOC_ARP,11)
  170. // Use arc_t structure.
  171.  
  172. #define    AR_INTERFACE_UP        MIOC_CMD(MIOC_ARP,9)
  173. // Bring an ARPing interface up.
  174. // Use arc_t structure.
  175. // In:
  176. //        arc_cmd = AR_INTERFACE_UP
  177. //        arc_name_offset = offset to name of interface
  178. //        arc_name_length = length of name of interface (including zero terminator)
  179.  
  180. #define    AR_INTERFACE_DOWN    MIOC_CMD(MIOC_ARP,10)
  181. // Tear an ARPing interface down.
  182. // Use arc_t structure.
  183. // In:
  184. //        arc_cmd = AR_INTERFACE_DOWN
  185. //        arc_name_offset = offset to name of interface
  186. //        arc_name_length = length of name of interface (including zero terminator)
  187.  
  188.  
  189. // Flags used in the arc_flags field of arc_t.
  190.  
  191. #define    ACE_F_PERMANENT        0x1        // This entry will not time out.
  192. #define    ACE_F_PUBLISH        0x2        // ARP will respond to incoming ARP requests for this entry
  193. #define    ACE_F_DYING            0x4        // This entry is going away very soon.
  194. #define    ACE_F_RESOLVED        0x8        // This entry is valid.
  195. #define ACE_F_MAPPING        0x10    // Use bit mask on target address.
  196.  
  197. // The protocol value for IP ARPs, for use in the arc_proto field of the arc_t.
  198.  
  199. #define    IP_ARP_PROTO_TYPE        0x0800
  200.  
  201.  
  202. #if PRAGMA_ALIGN_SUPPORTED
  203. #pragma options align=reset
  204. #endif
  205.